home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / java_eoe.idb / usr / java / bin / .java_wrapper.z / .java_wrapper
Encoding:
Korn shell script  |  1997-05-21  |  4.1 KB  |  144 lines

  1. #! /bin/ksh
  2. #
  3. #     @(#)java_wrapper.sh    1.27 97/04/28
  4. #
  5. #===================================================================
  6. # THIS SCRIPT AND JAVA WILL NOT RUN UNDER SUNOS4.X, AKA SOLARIS 1.X.  
  7. #===================================================================
  8.  
  9. function path_warn {
  10.   echo "Warning -- $2 not consistent with the Java home location."
  11.   echo $2 is: $1
  12.   echo JAVA_HOME is: $JAVA_HOME
  13.   if [[ $2 = CLASSPATH ]]
  14.   then
  15.    echo "We recommend not putting any system classes into CLASSPATH."
  16.    echo "(The java invocation script will add these in in the correct place.)"
  17.   else
  18.     if [[ $2 = LD_LIBRARY_PATH ]]
  19.     then
  20.      echo "We recommend not putting any system libraries into LD_LIBRARY_PATH."
  21.      echo "(The java invocation script will add these in in the correct place.)"
  22.     fi
  23.   fi
  24. }
  25.  
  26. function check_path {
  27.   if egrep -s '^/usr/java/|:/usr/java/' << EOF
  28. $1
  29. EOF
  30.   then
  31.     if ! egrep -s '^/usr/java$|^/usr/java/' << EOF
  32. $JAVA_HOME
  33. EOF
  34.     then
  35.       # CLASSPATH or LD_LIBRARY_PATH has components from /usr/java, but
  36.       # java components are not being taken from /usr/java.
  37.       path_warn $1 $2
  38.     fi
  39.   else
  40.     if egrep -s /usr/java/ << EOF
  41. $1
  42. EOF
  43.     then
  44.       if egrep -s '^/usr/java$|^/usr/java/' << EOF
  45. $JAVA_HOME
  46. EOF
  47.       then
  48.         # CLASSPATH or LD_LIBRARY_PATH has components from /usr/java under an
  49.     # alternate root, but java components are being taken from /usr/java.
  50.         path_warn $1 $2
  51.       fi
  52.     fi
  53.   fi
  54. }
  55.  
  56. # Set up default variable values if not supplied by the user.
  57.  
  58. PRG=`whence $0` >/dev/null 2>&1
  59. J_HOME=`dirname $PRG`/..
  60. progname=`basename $0`
  61.  
  62. # The default THREADS_TYPE is "green_threads".  To change the default change
  63. # the setting of the DEFAULT_THREADS_FLAG variable.  The only valid values 
  64. # of that variable are 'green' and 'native'. 
  65. # This introduces a dependency of this wrapper on the policy used to do builds.
  66. # e.g. the usage of the name "green_threads" here is dependent on the build
  67. # scripts which use the same name. Since this is somewhat analogous to the
  68. # wrapper already depending on the build scripts putting the executable in
  69. # a specific place (JAVA_HOME/bin/`uname -p`), the new dependency does not
  70. # seem all that bad.
  71.  
  72. DEFAULT_THREADS_FLAG=green
  73.  
  74. if [[ ${THREADS_FLAG:-${DEFAULT_THREADS_FLAG}} = native ]] ; then 
  75.     THREADS_TYPE=native_threads
  76. else
  77.     THREADS_TYPE=green_threads
  78. fi
  79. export THREADS_TYPE
  80. #echo "Using executables built for $THREADS_TYPE"
  81.  
  82. #
  83. # If the -noenv argument is specified, we set JAVA_HOME
  84. # and CLASSPATH to nothing, effectively ignoring those
  85. # environment variables.
  86. #
  87. # If one of java's '-*' options was specified on the command line,
  88. # then ksh insists on trying to interpret the option when
  89. # we do a set.  Worse, it swallows the option, refusing
  90. # to pass it on to (binary) java.  So we keep track of
  91. # all options and pass them on to eval by hand.
  92. #
  93. # Search for '-native' or '-green' flags, and remove them from the
  94. # arguments if found.  Also if found, set THREADS_TYPE to either
  95. # 'native_threads' or 'green_threads', as appropriate.  This is an
  96. # alternative to using the THREADS_FLAG environment variable to 
  97. # specify the threads package for Solaris.
  98.  
  99. for a in "$@"; do
  100.     case $a in
  101.     -native)
  102.         echo "-native is not supported in this release."
  103.         exit 1
  104.         ;;
  105.     -green)
  106.         THREADS_TYPE=green_threads
  107.         ;;
  108.         *) newargs="$newargs $a" ;;
  109.     esac
  110. done
  111.  
  112. # set $newargs 
  113.  
  114. if [ -z "$JAVA_HOME" ] ; then
  115.     export JAVA_HOME
  116.     JAVA_HOME=$J_HOME
  117. fi
  118.  
  119. CLASSPATH="${CLASSPATH-.}"
  120. check_path $CLASSPATH "CLASSPATH"
  121. if [ -z "${CLASSPATH}" ] ; then
  122.     CLASSPATH="$JAVA_HOME/classes:$JAVA_HOME/lib/classes.jar:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/i18n.jar:$JAVA_HOME/lib/classes.zip"
  123. else
  124.     CLASSPATH="$CLASSPATH:$JAVA_HOME/classes:$JAVA_HOME/lib/classes.jar:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/i18n.jar:$JAVA_HOME/lib/classes.zip"
  125. fi
  126.  
  127. export CLASSPATH
  128.  
  129. check_path $LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  130. LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$JAVA_HOME/lib/sgi/$THREADS_TYPE"
  131. export LD_LIBRARY_PATH
  132.  
  133. prog=$JAVA_HOME/bin/sgi/${THREADS_TYPE}/${progname}
  134.  
  135. if [ -f $prog ]
  136. then
  137.      exec $DEBUG_PROG $prog $opts $newargs
  138. else
  139.     echo >&2 "$progname was not found in ${prog}"
  140.     exit 1
  141. fi
  142.